/******************************************************************************/
/* Archivo:      test_m.c                                                     */
/* Autor:	     Omar Diaz                          				          */
/* Descripcion:  Programa en C para generar los estimulos de la memoria de	  */ 
/*				 intruccion.											      */
/*                                                                            */
/******************************************************************************/

#include <stdio.h>
#include "genpat.h"

/*char* inttostr(int entier) {
  char* str;
  str = (char *) mbkalloc (32 * sizeof(char));
  sprintf(str,"%d",entier);
  return(str);
}*/

main() {
  int i;
  char direcciones[15][9] = {	{"0b000000"},
								{"0b000001"},
								{"0b000010"},
								{"0b000011"},
								{"0b000100"},
								{"0b000101"},
								{"0b000110"},
								{"0b000111"},
								{"0b000000"},
								{"0b000001"},
								{"0b000010"},
								{"0b000011"},
								{"0b000100"},
								{"0b000101"},
								{"0b000110"}	 
  };
 
  DEF_GENPAT("test_c");

  //DECLAR("Clock"		,":2","B", IN	,     ""      , "");
  DECLAR("RESET_i"		,":2","B", IN	,     ""      , "");
  DECLAR("ADDRESS_i"      ,":2","B", IN	,"5  downto 0", "");
  DECLAR("DATA_o"		,":2","B", OUT	,"11 downto 0", "");
  DECLAR("vdd"			,":2","B", IN	,     ""      , "");
  DECLAR("vss"	      	,":2","B", IN	,     ""      , "");

  LABEL("Memoria");

  //Inicialización
  
  SETTUNIT("ns");
  AFFECT("0" , "vdd"		, "0b1");
  AFFECT("0" , "vss"		, "0b0");
  //AFFECT("0" , "Clock"		, "0");
  AFFECT("0", "RESET_i"		, "0b1");
  AFFECT("0", "ADDRESS_i"	, "0b000000");

  //Simulación
  
  AFFECT("+50", "RESET_i"		, "0b0");
  
  for(i=0; i<15; i++) {
  	AFFECT("+50", "ADDRESS_i"	    , direcciones[i]);
  	//AFFECT("+50", "Clock"		, inttostr(i%2));
  }

  SAV_GENPAT();
  exit(0);
}

